package com.shop.cereshop.admin.controller.online;

import com.shop.cereshop.admin.service.online.OnlineUserService;
import com.shop.cereshop.commons.domain.buyer.CereBuyerUser;
import com.shop.cereshop.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("online")
@Api(tags = "在线用户统计")
@RequiredArgsConstructor
public class OnlineUserController {

    private final OnlineUserService onlineUserService;

    @GetMapping("count")
    @ApiOperation("获取在线用户数量")
    public Result<Integer> getOnlineUserCount() {
        int count = onlineUserService.getOnlineUserCount();
        return new Result<>(count);
    }

    @GetMapping("users")
    @ApiOperation("获取在线用户列表")
    public Result<List<CereBuyerUser>> getOnlineUsers() {
        List<CereBuyerUser> users = onlineUserService.getOnlineUsers();
        return new Result<>(users);
    }
}
